package com.quectel.util.security;

import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTCreator;
import com.auth0.jwt.algorithms.Algorithm;

import java.util.UUID;

public class TokenUtils {


    /**
     * 生成随机token
     *
     * @return token字符串, 若失败则返回null
     */
    public static String genRandomToken() {
        Algorithm algorithm = Algorithm.HMAC256(UUID.randomUUID().toString());
        JWTCreator.Builder builder = JWT
                .create()
                .withJWTId(UUID.randomUUID().toString());
        return builder.sign(algorithm);
    }

    public static void main(String[] args) {
        System.out.println(genRandomToken());
    }


}
